<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@include file="../../include/head.jsp"%>

<div class="container_12 ">

    <div class="grid_12 mgbt bgw">

        <div class="p10">
            <table class="list mgb_10" id="table_app">
                <thead class="ui-state-default">
                <tr>
                    <th>APP名称</th>
                    <th>地址</th>
                    <th>表达式</th>
                    <th>当前状态</th>
                    <th class="tooltd">工具</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${apps}" var="app">
                    <tr>
                        <td>${app.value.app.name}</td>
                        <td>${app.value.app.url}</td>
                        <td>${app.value.app.regular}</td>
                        <td>${app.value.statusLine}</td>
                        <td class="tooltd"><a href="javascript:reloadApp('${app.value.app.url}')">刷新</a></td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
    </div>

    <div class="grid_12  bgw">

        <div class="p10">
        <table class="list " id="table_list">
            <thead class="ui-state-default">
            <tr>
                <th>主机</th>
                <th>IP</th>
                <th>表达式</th>
                <th>当前状态</th>
                <th class="tooltd">工具</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${hoststatus}" var="status">
                <tr>
                    <td>${status.value.host.name}</td>
                    <td>${status.value.host.ip}</td>
                    <td>${status.value.host.regular}</td>
                    <td>${status.value.hostInfo != null?"<span class='green'>正常</span>":"<span class='red'>异常</span>"}</td>
                    <td class="tooltd">
                        <c:if test="${status.value.hostInfo != null}">
                            <a target="_blank" href="/app?action=Default&method=hostInfo&host=${status.value.host.ip}">状态</a>&nbsp;&nbsp;
                        </c:if>
                        <a target="_blank" href="javascript:reloadHost('${status.value.host.ip}')">刷新</a>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
        </div>
    </div>
</div>
<script>
    //APP刷新
    function reloadApp(url){
        $.get('/app?action=Default&method=reloadApp',{url:url},function(result){
            if(result == 'success'){
                window.location.reload();
            }
        });
    }
    //HOST刷新
    function reloadHost(host){
        $.get('/app?action=Default&method=reloadHost',{ip:host},function(result){
            if(result == 'success'){
                window.location.reload();
            }
        });
    }
</script>
<%@include file="../../include/foot.jsp"%>